<template>
  <view class="history_container">
    <view class="top">
      {{todayText}}
    </view>
    <view class="content_container">
      <view class="item_box" v-for="(item,index) in list" :key="index">
        <view class="item_img">
          <image src="https://cdn.pixabay.com/photo/2018/02/01/14/09/field-3123271_1280.jpg"></image>
        </view>
        <view class="item_year">
          {{item.year}}年
        </view>
        <view class="item_title">
          {{item.title}}
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    getHistoryToday
  } from "../api/list.js"
  export default {
    data() {
      return {
        todayText: "",
        list: [],
      }
    },
    onLoad() {

    },
    onShow() {
      this.getList()
    },
    methods: {
      async getList() {
        let date = new Date()
        let month = date.getMonth() + 1
        let day = date.getDate()
        this.todayText = `${date.getMonth() + 1}月${day}日`
        let today = `${month}/${day}`
        const res = await getHistoryToday({
          date: today
        })
        res.data.data = JSON.parse(res.data.data);
        this.list = res.data.data
		this.list.map(item => {
			item.year = item.date.split("年")[0]
		})
      }

    }
  }
</script>

<style lang="less" scoped>
  .history_container {
    margin: 0 auto;
	padding-bottom: 60rpx;
	box-sizing: border-box;
    .top {
      width: 100%;
      height: 300rpx;
      background: url("https://cdn.pixabay.com/photo/2023/12/15/22/37/mountains-8451480_1280.jpg") no-repeat;
      background-size: cover;
      border-radius: 10rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 48rpx;
	  font-weight: bold;
      color: #fff;
    }

    .content_container {
      margin-top: 20rpx;
      padding: 0 40rpx;
      box-sizing: border-box;

      .item_box {
        width: 100%;
        border-radius: 14rpx;
        background-color: #fff;
        margin-bottom: 40rpx;
        padding-bottom: 20rpx;
        box-sizing: border-box;

        .item_img {
          width: 100%;
          height: 340rpx;

          image {
            width: 100%;
            height: 100%;
            border-top-left-radius: 14rpx;
            border-top-right-radius: 14rpx;
          }
        }

        .item_year {
          width: 100%;
          height: 60rpx;
          line-height: 60rpx;
          padding-left: 20rpx;
          box-sizing: border-box;
          font-size: 33rpx;
          background-color: #4faf70;
          color: #fff;
          margin-top: 20rpx;
        }

        .item_title {
          width: 100%;
          font-size: 36rpx;
          font-weight: bold;
          color: #000;
          // white-space: nowrap;
          // text-overflow: ellipsis;
          // overflow: hidden;
          padding: 20rpx;
          box-sizing: border-box;
        }
      }
    }
  }
</style>